<!DOCTYPE html>
<html lang="en">

<head>

    <include file="Public/header" />
	

</head>

<body>

    <div id="wrapper">

        <include file="Public/nav" />

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">{$Think.lang._add_user_}</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>

            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        	{$Think.lang._add_user_}
                        </div>
                        
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	<div class="row">
                            	<form id="add_form" role="form">
                            		<div class="col-lg-6">
	                            		<div class="form-group">
	                                         <label>{$Think.lang._username_}</label>
	                                         <input name="username" type="text" class="form-control" 
	                                         required="" data-parsley-minlength="4" data-parsley-minlength-message="{$Think.lang._reg_username_minlength_}" 
	                                         data-parsley-maxlength="20" data-parsley-maxlength-message="{$Think.lang._reg_username_maxlength_}" 
	                                         data-parsley-required-message="{$Think.lang._username_} {$Think.lang._required_}" placeholder="{$Think.lang._reg_input_placeholder_}{$Think.lang._username_}">
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                         <label>{$Think.lang._reg_password_}</label>
	                                         <input class="form-control" id="password" name="password" 
									type="password" required="" data-parsley-minlength="6" 
									data-parsley-minlength-message="{$Think.lang._reg_password_minlength_}" 
									data-parsley-maxlength="20" data-parsley-maxlength-message="{$Think.lang._reg_password_maxlength_}"
									 data-parsley-required-message="{$Think.lang._reg_password_} {$Think.lang._required_}" placeholder="{$Think.lang._reg_input_placeholder_}{$Think.lang._reg_password_}">
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                         <label>{$Think.lang._state_}</label>
	                                         <select name="status" class="form-control" >
	                                         	<option value="1">{$Think.lang._open_}</option>
	                                         	<option value="0">{$Think.lang._disable_}</option>
	                                         </select>
	                                     </div>
	                                     
	                                     <div class="form-group">
	                                         <label>{$Think.lang._role_}</label>
	                                         <select name="group_id" class="form-control" >
	                                         	<volist name="groups" id="vo">
	                                         		<option value="{$vo.id}">{$vo.title}</option>
	                                         	</volist>
	                                         </select>
	                                     </div>
	                                     
	                                     
	                                     <div class="form-group">
	                                     	<button type="submit" class="btn btn-default">{$Think.lang._submit_}</button>
	                                     	<button type="reset" class="btn btn-default">{$Think.lang._reset_}</button>
	                                     	<a href="javascript:history.back(-1)" type="button" class="btn btn-default">{$Think.lang._return_}</a>
	                                     </div>
	                                     
                                     </div>
                            	</form>
                        	</div>

                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-6 -->
                <!-- /.col-lg-6 -->
            </div>
            
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <include file="Public/footer" />
	<script type="text/javascript" src="__RAC__/js/parsleyjs/parsley.min.js"></script>
	
	<script type="text/javascript">
	$(function () {
		$('#add_form').parsley().on('form:submit', function() {
        	var obj = $('#add_form').serialize();
        	var layer_index = null;
           	$.ajax({
           	    type: "POST",
           	    url: "{:U('Admin/add_form')}",
           	    data: obj,// 要提交的表单
           	    dataType: 'json',
           	    beforeSend: function(){
   					layer_index = layer.load(1, {
   					  	shade: [0.1, '#ccc'] //0.1透明度的白色背景
   					});
   				},
           	    success: function (data, response) {
           	    	layer.close(layer_index);
           	    	if (data.flag > 0) {
           	    		//location.href = "{:U('Admin/index')}";
           	    		layer.msg(data.msg);
           	    	} else {
           	    		layer.msg(data.msg);
           	    	}
           	    },
           	    error: function (error) {
           	    	layer.close(layer_index);
           	    	layer.msg('error');
           	    }
           	  });
        	  
        	 return false;
        });
		
	});
	
	</script>
</body>

</html>
